import { ErrorMapper } from './module/errorMapper'
import mountWork from './mount'
import mountWork2 from './prototype'
import {adaption_body, cleanDeadCreep, GenerateAbility, setCPU} from './utils'
import RoomFrame from './run/RoomFrame'
import { globalMisson } from './module/globalMisson/work'
import CreepFrame from './run/CreepFrame'
import { InterShardRun, InitShardMemory } from './shard/base'
import { SquardManager } from './squard/squard'
export const loop = ErrorMapper.wrapLoop(() =>{
    var mainStartCpu = Game.cpu.getUsed()
    /* 清除死去爬虫的记忆 */
    if (Game.shard.name == 'shard2' && Game.cpu.bucket >= 10000)
        Game.cpu.generatePixel()
    cleanDeadCreep()
    InitShardMemory()
    /* 跨区记忆运行 */
    InterShardRun()
    /* 挂载原型拓展 */
    mountWork() 
    mountWork2()
    /* 全局任务执行 */
    globalMisson()
    // 执行
    RoomFrame()
    // 爬虫运行
    if (Game.cpu.bucket < 200 && Game.shard.name == 'shard3') return
    CreepFrame()

    // 小队运行
    SquardManager()
    var mainEndCpu = Game.cpu.getUsed()
    // cpu统计相关操作
    setCPU(mainEndCpu,mainStartCpu)
    // console.log(adaption_body(GenerateAbility(10,10,20,0,0,0,0,0),1500))
})
